package com.raos.example.config;

import dev.langchain4j.web.search.searchapi.SearchApiWebSearchEngine;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * 联网搜索能力初始化
 *
 * @author raos
 * @date 2025-03-27
 */
@Configuration
@RequiredArgsConstructor
public class WebSearchInit {

    final SearchConfig searchConfig;

    @Bean
    public SearchApiWebSearchEngine initWebSearchEngine() {
        return SearchApiWebSearchEngine.builder()
            .engine(searchConfig.getEngine())
            .apiKey(searchConfig.getApiKey())
            .build();
    }

}
